/*This file is part of AENIMA. AENIMA is a module of BCI++ framework for the implementation of brain computerinterface systems. 
AEnima is intended for use with BCI++ only.

BCI++ is a project of the Sensibilab of the Politecnico di Milano. 

AENIMA is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as 
published by the Free Software Foundation, either version 3 of 
the License, or (at your option) any later version.

AENIMA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU General Public License
and the GNU Lesser General Public License along with AENIMA.  
If not, see <http://www.gnu.org/licenses/>.*/

/*!
	\file	SocketComm.h
	 Header file for Socket
	 
	\author	sensibilab E-Mail: info.sensibilab@polimi.it

	\date	2007-09-06 creation \n
		2009-01-27 last modification

	\b COPYRIGHT: 
		This program is property of Sensibilab - Campus Ponit - Lecco
*/

#pragma once

#include "Constants.h"
#include <winsock2.h>
#include <iostream>
#include "SocketComm_base.h"

#include "structs\BCIMessage.h"

using namespace std;
/*!\class SocketComm
Class to manage the client Socket*/
class SocketComm: public SocketComm_base
{
	/*SOCKET lhSocket;
	SOCKADDR_IN lSockAddr;
	WSADATA wsaData;
	hostent *myHost;*/
public:
	SocketComm(void);
	/*!\fn ~SocketComm(void)
	When the SocketComm destructor is called, the function WSACleanup cleans al socket that was created
	and used in the software.*/
	~SocketComm(void);
	/*!\fn void Open(char *ipAddress, int SockPort)
	Function to create the socket,
	\param ipAddress IP address (or PC name) of the server.
	\param SockPort Socket Prot: is fixed to 3001.*/
	int Open(char *ipAddress, int SockPort);
	/*!\fn void Connect(void)
	Function to connect the software with the created socket.*/
	void Connect(void);
	/*!\fn int SendData(BCIMessage *myDataOut)
	This function is used to send data to the server.*/
	int SendData(BCIMessage *myDataIn);
	/*!\fn void Close(void)
	This function closes the socket connection.*/
	void Close(void);
	/*!\fn int RecvData(BCIMessage *myDataIn)
	Function to receive data from server.*/
	int RecvData(BCIMessage *myDataIn);
	/*DWORD WINAPI RecvThread( LPVOID lpParam );
	DWORD WINAPI SendThread( LPVOID lpParam );
	void CreateRecvThread(int *isWindowActive);
private:
	static DWORD WINAPI S_RecvThread(LPVOID *lpParam);*/
};
